home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 476-500 / disk_498 / zoomdaemon / source / zoom-setup.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  3KB  |  109 lines

  1. /*
  2.  *  ZOOM-DAEMON   A program that implements Zoom gadgets for all Intuition
  3.  *                windows that are opened while it is running.
  4.  *
  5.  *              Copyright 1989 by Davide P. Cervone.
  6.  *  You may use this code, provided this copyright notice is kept intact.
  7.  */
  8.  
  9. #include "Zoom-Handler.h"
  10.  
  11. struct IntuitionBase *IntuitionBase = NULL;
  12. struct SysBase *SysBase;
  13.  
  14. /*
  15.  *  These are the assembly code stubs that replace the Intuition Library
  16.  *  vectors.  Thes stubs in turn call the C-language routines that actually
  17.  *  do the work.
  18.  */
  19.  
  20. extern void aOpenWindow();
  21. extern void aCloseWindow();
  22. extern void aAddGadget();
  23. extern void aAddGList();
  24.  
  25.  
  26. /*
  27.  *  These are used by the assembly stubs to call the original routines when
  28.  *  needed.  They also are used to replace the Intution vectors when 
  29.  *  Zoom-Daemon exits.
  30.  */
  31.  
  32. long OldOpenWindow;
  33. long OldCloseWindow;
  34. long OldAddGadget;
  35. long OldAddGList;
  36.  
  37.  
  38. /*
  39.  *  These are the structures that need to be passed to the loader
  40.  *  so that it can clean up after Zoom-Handler is removed.
  41.  */
  42.  
  43. extern struct ExtGadget *FirstZoom;
  44.  
  45. extern void ZoomHandlerStub();
  46. extern void cOpenWindow();
  47.  
  48.  
  49. static struct Interrupt Zoom_Interrupt =  /* the Interrupt needed to add a */
  50. {                                         /*  handler to the input chain */
  51.    {NULL, NULL, 0, 51, NULL},             /*  ln_Pri = 51 (before Intuition) */
  52.    NULL,
  53.    &ZoomHandlerStub                       /* the handler to add */
  54. };
  55.  
  56.  
  57. /*
  58.  *  This is the main structure passed from the handler to the loader.
  59.  *  It is used to exchange variables between the loader and the handler
  60.  *  (like IntuitionBase, and any application-specific structures that
  61.  *  need to be initialized or freed by the loader).
  62.  */
  63.  
  64. static struct Zoom_HandlerInfo Zoom_HandlerData =
  65. {
  66.    {                                            /* the MsgPort is pre-setup */
  67.       {NULL,NULL, NT_MSGPORT, 0, PORTNAME},     /*  to include the name and */
  68.       PA_IGNORE, 0, NULL,                       /*  type so that it can just */
  69.       {NULL,NULL,NULL, 0,0}                     /*  be added to the port list */
  70.    },                                           /*  so it can be found later */
  71.    MAJVERS,MINVERS, MINLOADVER,
  72.    NULL,
  73.    &IntuitionBase,
  74.    &SysBase,
  75.    
  76.    &Zoom_Interrupt,
  77.    
  78.    &aOpenWindow,
  79.    &aCloseWindow,
  80.    &aAddGadget,
  81.    &aAddGList,
  82.  
  83.    &OldOpenWindow,
  84.    &OldCloseWindow,
  85.    &OldAddGadget,
  86.    &OldAddGList,
  87.  
  88.    &cOpenWindow,
  89.    &FirstZoom
  90. };
  91.  
  92.  
  93. /*
  94.  *  Setup()
  95.  *
  96.  *  This routine MUST be linked into the Zoom-Handler executable 
  97.  *  as the first routine, so that the loader can find it.
  98.  *  It should check the version number for compatibility with the loader,
  99.  *  and should return NULL for an error, or the pointer to the shared
  100.  *  data structure if everything is OK.
  101.  */
  102.  
  103. struct Zoom_HandlerInfo *Setup(version)
  104. int version;
  105. {
  106.    if (version < MINLOADVER) return(NULL);
  107.    return(&Zoom_HandlerData);
  108. }
  109.